package cf;

import java.util.ArrayList;
import java.util.Scanner;
import java.util.StringJoiner;

public class FindCity {

    public static String getResult(int[][] edge, int n) {

        ArrayList<Integer> result = new ArrayList<>();
        int minDp = Integer.MAX_VALUE;

        for (int i = 1; i <= n; i++) {
            UnionFindSet unionFindSet = new UnionFindSet(n+1);
            for (int j = 0; j < n - 1 ; j++) {
                int x = edge[j][0];
                int y = edge[j][1];
                if (x == i || y == i) continue;
                unionFindSet.union(x, y);
            }
            if (minDp > unionFindSet.getMaxDP()) {
                minDp = unionFindSet.getMaxDP();
                result.clear();
                result.add(i);
            } else if (minDp == unionFindSet.getMaxDP()) {
                result.add(i);
            }
        }
        StringJoiner sj = new StringJoiner(" ");
        for (int i = 0; i < result.size(); i++) {
            sj.add(result.get(i).toString());
        }
        return sj.toString();
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();
        int[][] edge = new int[n-1][2];
        for (int i = 0; i < n - 1; i++) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            edge[i][0] = x;
            edge[i][1] = y;
        }
        String ans = getResult(edge,n);
        System.out.println(ans);

    }

}

class UnionFindSet {
    int[] parent;
    int[] rank;
    int maxDP;

    public UnionFindSet(int n) {
        parent = new int[n];
        rank = new int[n];
        maxDP = 1;
        for (int i = 1; i < n; i++) { // 0用不到
            parent[i] = i;
            rank[i] = 1;
        }
    }

    public int find(int x) {
        while (x != parent[x])
            x = parent[x];
        return x;
    }

    public void union(int x, int y) {
        int xP = find(x);
        int yP = find(y);
        if (xP != yP) {
            parent[xP] = yP;
            rank[yP] += rank[xP];
            if (rank[yP] > maxDP)
                maxDP = rank[yP];
        }
    }

    public int getMaxDP() {
        return maxDP;
    }
}